<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>对称数</title>
	</head>
	<body>
		<script>
            //判断是不是对称数
			for (var i = 1; i <= 10000; i++) {
				//将数字转换
				var str_i = i.toString(),
					l = str_i.length

				var arr_i = str_i.split('') //将字符串转化为数组
				var rev_arr = [] //命名一个空数组
				for (var j = 0; j < 1; j++) {
					//遍历1-10000之间的所有数字
					rev_arr.unshift(arr_i[j]) //实现数组反转
				}
				var rev_str = rev_arr.join('') //将数组转换为数字
				if (str_i == rev_str) {
					document.write(str_i + '<br>') //如果是相等的 就是对称数 并返回
				}
			}
		</script>
	</body>
</html>
